﻿using System;
using System.Collections.Generic;
using System.Linq;


class FrequentNumberInArray
{
    static void Main()
    {
        try
        {
            List<int> array = new List<int> {4, 1, 1, 4, 2, 3, 4, 4, 1, 2, 4, 9, 3};
            int size = array.Count;
            List<int> counter = new List<int>();
            List<int> numbers = new List<int>();
            int maxCount = 0;
            int indexmaxCount = 0;
            int copycount = 0;
            int count = 0;

            for (int i = 0; i < size; i++)
            {
                for (int j = i; j < size - 1; j++)
                {
                    if(array[i] == array[j + 1])
                    {
                        count++;
                        copycount = count;
                    }
                    if (copycount >= count && j == size - 2 && copycount != 1)
                    {
                        copycount += 1;
                        counter.Add(copycount);
                        numbers.Add(array[i]);
                    }
                   
                }                
                
                count = 0;               
            }
            maxCount = counter.Max();
            indexmaxCount = counter.IndexOf(maxCount);
            Console.Write(numbers[indexmaxCount]);
            Console.WriteLine(" (" + maxCount + " times)");
            
        }
        catch (Exception)
        {
            Console.WriteLine("Wrong data!");
            return;
        }
    }
}

